package chess;

/**
 *
 * @author Anthony Hilyard
 */
public class King extends Piece
{    
    public King(int color)
    {
        pieceColor = color;
    }//end of constructor
    
    public int canMove(int sourceX, int sourceY, int destX, int destY)
    {
        // Return false if coordinates are outside of the board.
        if(sourceX < 0 || sourceX > 7 || sourceY < 0 || sourceY > 7 ||
                destX < 0 || destX > 7 || destY < 0 || destY > 7)
            return 0;
        
        // Source and destination locations should be different.
        if(sourceX == destX && sourceY == destY)
            return 0;
        
        if(Math.abs(destX - sourceX) <= 1 && Math.abs(destY - sourceY) <= 1)
        { // If the distance moved on X and Y is 1 or less, it is a valid move.
            return 1;
        } 
        else
        {
            return 0;
        }        
       
    }//end of canMove
    
    public char getType()
    {
        return 'K';
    }//end of getType
    
    public static int getValue()
    {
        return 100;
    }//end of getValue
    
    
}//end of King
